# 0. warming up
URL: http://www.pythonchallenge.com/pc/def/0.html
Flag: http://www.pythonchallenge.com/pc/def/274877906944.html
Python docs
In [7]:
pow(2, 38)
Out[7]:
URL: http://www.pythonchallenge.com/pc/def/map.html
Flag: http://www.pythonchallenge.com/pc/def/ocr.html
Python docs
str.maketrans()str.translate()printf-style string formatingOther resources
In [20]:
from string import ascii_lowercase as al
# Build Caesar table using a shift of 2
table = str.maketrans(al, al[2:] + al[:2])
hint = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."
print("Hint: \"%s\"\n" % hint.translate(table))
cypher_flag = 'map'
flag = cypher_flag.translate(table)
print(f'Flag: \"{flag}\"')
In [30]:
import requests
import re
webpage = requests.get('http://www.pythonchallenge.com/pc/def/ocr.html').text
# Filter comments
comments = re.findall(r'<!--([^>]*)-->', webpage)
cypher_flag = comments[1] # Get second comment
# Guessed a "rare" character in a mess was something readable, so anything that is alphabetic
regex = re.findall(r'[a-z]', cypher_flag)
lc = ''.join([x for x in cypher_flag if x.isalpha()])
print('Using regex:', regex)
print('Using isalpha:', lc)
In [34]:
import requests
import re
# Load website and comment
webpage = requests.get('http://www.pythonchallenge.com/pc/def/equality.html').text
cypher_flag = re.findall(r'<!--([^>]*)-->', webpage)[0]
# One letter surrounded by EXACTLY three big bodyguards on each of its side = 3 upper, 1 lower, 3 upper (EXACTLY)
matches = re.findall(r'[a-z][A-Z]{3}[a-z][A-Z]{3}[a-z]', cypher_flag)
''.join([x[4] for x in matches])
Out[34]: